package com.shoujifeng.snowmusic.ListView;

import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.shoujifeng.snowmusic.player.R;
import com.shoujifeng.snowmusic.player.utils.SharedPreferencesUtil;
/**
 * 
 * @������:�Զ���Toast
 * 
 */
public class NewToast extends Toast {  
    private static Toast toast;
    private static SharedPreferencesUtil share;
	private static int screen_width, screen_height;// �ֻ���Ļ�Ŀ��
    public NewToast(Context context) {  
        super(context);  
    }  
      
    public static Toast makeText(Context context,CharSequence text, int duration) {  
    	share=new SharedPreferencesUtil(context);
		screen_width=share.getPhoneWidth();
		screen_height=share.getPhoneHeight();
    	if(toast!=null){
    		toast.cancel();
    	}else{    		
    		toast = new Toast(context);  
    	}
        //��ȡLayoutInflater����  
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);   
        //��layout�ļ�����һ��View����  
        View layout = inflater.inflate(R.layout.newtoast, null);  
          
        //ʵ��ImageView��TextView����  
        TextView textView = (TextView) layout.findViewById(R.id.text0);  
        textView.setText(text);  
          
        toast.setView(layout);  
        toast.setGravity(Gravity.CENTER_VERTICAL, 0, (int)(screen_height*0.2f));  
        toast.setDuration(duration);  
          
        return toast;  
    }  
  
}  
